#ifndef TASK_H
#define TASK_H

#include <peripheral/ports.h>
#include <peripheral/system.h>
#include <peripheral/int.h>
#include <peripheral/timer.h>
#include "stack.h"
#include "tick.h"
#include "config.h"
#include "idle.h"

struct task
{
	unsigned int gpr [32];
	void *epc;
	unsigned int id;
	unsigned int wait; // There are 31 semaphores. If the most significant bit is set
};                   // the task is waiting for one or more semaphores. Otherwise, 
                     // it is waiting some number of ticks. 

/*
	 create a task. 
*/
unsigned int taskCreate (void (*function) (void *parameters), unsigned int stackWords, void *parameters);

/*
	 dealay the running task until some number of ticks have gone by
*/
void taskDelay (unsigned int ticks);

void createIdleTask (void);
void startScheduler (void);

static unsigned int getTaskID (void);
//void idleTask (void);
#endif

